package 代码记录.指定公司代码练习记录.华为_2024.分值100;

import java.util.Scanner;

/**
 * @author zx
 * @create 2024-01-26 22:48
 * 自己可以做出来
 */
public class 字符串序列判定_1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String l = sc.nextLine();
        int temp = 0;
        int len = s.length();
        int res = 0;
        for(int i = 0;i < l.length();i++){
            if(s.charAt(temp) == l.charAt(i)){
                temp++;
            }
            if(temp == len){
                res = i;
                break;
            }
        }
        if (res > 0 && temp == len) {
            System.out.println(res);
        } else {
            System.out.println(-1);
        }
    }
}
